package com.tbs.parkingsaleapp.Http.Listenner;

import abstergo.tbs.betterasyc.AsycBase.IAsycBackgroundAction;
import abstergo.tbs.betterasyc.AsycBase.IAsycResultAction;
import abstergo.tbs.betterasyc.Handler.HandlerMananger;
import android.os.Message;
import com.alibaba.fastjson.JSON;
import com.tbs.parkingsaleapp.Http.HttpHelper;
import com.tbs.parkingsaleapp.Http.JsonData.DiscountInfo;
import com.tbs.parkingsaleapp.SystemManager.Handler.HandlerConst;
import com.tbs.parkingsaleapp.SystemManager.NetWorkSetting;

public class DiscountGetter implements IAsycResultAction<DiscountInfo[]>, IAsycBackgroundAction<Integer,DiscountInfo[]> {
    @Override
    public DiscountInfo[] BackGroundAction(Integer... params) throws Exception {
        String r= HttpHelper.Get(NetWorkSetting.getDiscountUrl(params[0]));
        return JSON.parseObject(r,DiscountInfo[].class);
    }

    @Override
    public void ResultFunction(DiscountInfo[] result) {
       Message msg= HandlerMananger.MakeMsg(HandlerConst.UseableDiscountGET);
       msg.obj=result;
       HandlerMananger.Instance().SendMsg(msg);
    }
}
